package com.yhq.ojbackendquestionservice.controller.inner;

import com.yhq.ojbackendquestionservice.service.QuestionService;
import com.yhq.ojbackendquestionservice.service.QuestionSubmitService;
import com.yhq.ojbackendserviceclient.service.QuestionFeignClient;
import com.yhq.ojbackendmodel.model.entity.Question;
import com.yhq.ojbackendmodel.model.entity.QuestionSubmit;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @program: oj-backend-microservice
 * @description: 题目控制器（该服务仅供内部调用）
 * @author: HenryYang
 * @create: 2023-09-03 16:13
 **/
@RestController
@RequestMapping("/inner")
public class QuestionInnerController implements QuestionFeignClient {
    @Resource
    private QuestionService questionService;
    @Resource
    private QuestionSubmitService questionSubmitService;
    @Override
    @GetMapping("/get/id")
    public Question getQuestionById(@RequestParam("questionId") long questionId){
        return questionService.getById(questionId);
    }
    @Override
    @GetMapping("/question_submit/get/id")
    public QuestionSubmit getQuestionSubmitById(@RequestParam("questionSubmitId") long questionSubmitId){
        return questionSubmitService.getById(questionSubmitId);
    }

    /**
     * 更新题目提交
     * @param questionSubmit
     * @return
     */
    @Override
    @PostMapping("/question_submit/update")
    public Boolean updateQuestionSubmitById(@RequestBody QuestionSubmit questionSubmit){
        return questionSubmitService.updateById(questionSubmit);
    }

}